package com.mhs.pb.domain;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Relation entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "relation", catalog = "PersonalRelation")
public class Relation implements BaseEntity {

// Fields

private static final long serialVersionUID = 7115261964893523750L;

private Long id;
private Basicinfo basicinfo;
private Account account;
private String relationtype;
private String extendinfo;
private Set<Record> records = new HashSet<Record>(0);
private Set<Account> accounts = new HashSet<Account>(0);
private Set<Resource> resources = new HashSet<Resource>(0);

// Constructors

/** default constructor */
public Relation() {
}

/** minimal constructor */
public Relation(Basicinfo basicinfo) {
	this.basicinfo = basicinfo;
}

/** full constructor */
public Relation(Basicinfo basicinfo, Account account, String relationtype,
        String extendinfo, Set<Record> records, Set<Account> accounts,
        Set<Resource> resources) {
	this.basicinfo = basicinfo;
	this.account = account;
	this.relationtype = relationtype;
	this.extendinfo = extendinfo;
	this.records = records;
	this.accounts = accounts;
	this.resources = resources;
}

// Property accessors
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Long getId() {
	return this.id;
}

public void setId(Long id) {
	this.id = id;
}

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "basicinfo", nullable = false)
public Basicinfo getBasicinfo() {
	return this.basicinfo;
}

public void setBasicinfo(Basicinfo basicinfo) {
	this.basicinfo = basicinfo;
}

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "relatedaccount")
public Account getAccount() {
	return this.account;
}

public void setAccount(Account account) {
	this.account = account;
}

@Column(name = "relationtype", length = 80)
public String getRelationtype() {
	return this.relationtype;
}

public void setRelationtype(String relationtype) {
	this.relationtype = relationtype;
}

@Column(name = "extendinfo", length = 65535)
public String getExtendinfo() {
	return this.extendinfo;
}

public void setExtendinfo(String extendinfo) {
	this.extendinfo = extendinfo;
}

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "relation")
public Set<Record> getRecords() {
	return this.records;
}

public void setRecords(Set<Record> records) {
	this.records = records;
}

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "relation")
public Set<Account> getAccounts() {
	return this.accounts;
}

public void setAccounts(Set<Account> accounts) {
	this.accounts = accounts;
}

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "relation")
public Set<Resource> getResources() {
	return this.resources;
}

public void setResources(Set<Resource> resources) {
	this.resources = resources;
}

}